<!--
// +----------------------------------------------------------------------
// | Created by PHPstorm: JRKAdmin框架 [ JRKAdmin ]
// +----------------------------------------------------------------------
// | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved.
// +----------------------------------------------------------------------
// | SiteUrl: http://www.luckyhhy.cn
// +----------------------------------------------------------------------
// | Author: LuckyHhy <jackhhy520@qq.com>
// +----------------------------------------------------------------------
// | Date: 2020/3/21 0021-15:21
// +----------------------------------------------------------------------
// | Description:
// +----------------------------------------------------------------------
*-->
{extend name="admin@public/window" /}

{block name="content"}


<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" lay-filter="form">

                <div class="layui-form-item">
                    <label class="layui-form-label">选择插件：</label>
                    <div class="layui-input-inline input-custom-width">
                        <select name="addons" lay-verify="" lay-filter="addons">
                            <option value="0">请选择插件</option>
                            {foreach name="addons" id="model"}
                            <option value="{$model['name']}">{$model.title}</option>
                            {/foreach}
                        </select>
                        <p class="help-block">关联的插件名称，可不选。</p>
                    </div>

                </div>
                {:token()}

                <div class="layui-form-item">
                    <label class="layui-form-label">钩子名称：</label>
                    <div class="layui-input-inline input-custom-width">
                        <input type="text" name="name" lay-verify="required" placeholder="请输入钩子名称" lay-vertype="tips"
                               lay-reqtext="请输入栏目名称" autocomplete="off" class="layui-input">
                        <p class="help-block">钩子名称只允许字母加数字和下划线。</p>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">类型：</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="type" value="1" title="视图" checked>
                        <input type="radio" name="type" value="2" title="控制器">
                    </div>

                    <label class="layui-form-label">状态：</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="status" value="1" title="启用" checked>
                        <input type="radio" name="status" value="0" title="禁用">
                    </div>
                </div>

                {if(isset($info['id']))}
                <input type="hidden" name="id" value="{$info.id}">
                {/if}

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">钩子描述：</label>
                    <div class="layui-input-block input-custom-width">
                        <textarea name="description" placeholder="请输入钩子描述" class="layui-textarea"></textarea>
                    </div>
                </div>

                {:widget('common/forms/submit',array('add','立即提交',2))}

            </form>


        </div>
    </div>
</div>


<script>
    layui.use(['element', 'form', 'jquery', 'lucky'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var lucky = layui.lucky;

        var info = {:json_encode($info)};
        form.val("form", info);
        form.render();

        form.on('submit(add)', function (data) {
            lucky.FormSubmit("{:url('addHook')}", data.field, "table_id", 1);
            return false;
        });
    })
</script>

{/block}